home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
stazsoftware.com
/
www.stazsoftware.com.tar
/
www.stazsoftware.com
/
futurebasic
/
sample-code
/
UpdateButton.sit
/
FN SetButtonValue
next >
Wrap
Text File
|
2003-11-18
|
2KB
|
62 lines
/*
this function performs two important tasks
task #1: it will not reset a button if it is already set
to the desired value.
task #2: it resets the clip region of a window so that
the change in the button is immediately apparent.
i know that i have reset embedded appearance buttons
about a zillion times and wondered why my code didn't work
only to discover that the code was fine, but the
update was clipped out of the window.
task #3: [who said i could count] it ensures that the new value
is within the min/max parameters of the control. in the
olden days [circa system 9] this was not a requirement.
with the appearance manager, many controls can be set
outside of their own min/max ranges.
task #4: after determining the proper value for the button and
setting it, it returns the new value to you as a result
of the function. if you try to set the control to an
improper value, you will learn (by looking at the fn
result) what the control was really set to. [did i just
end a sentence with a preposition?]
to use this, instead of calling...
button bRef , newValue
call the function with...
fn setButtonValue ( bRef , newValue )
now that i have begun to use this function, my hair is
starting to grow back.
*/
local fn setButtonValue ( bRef as long , value as long)
'~'9
dim min as long
dim max as long
dim cH as handle
dim rgn as rgnHandle
cH = button&(bRef)
long if ch
max = fn GetControlMaximum(cH)
min = fn GetControlMinimum(cH)
if value > max then value = max
if value < min then value = min
rgn = fn NewRgn
GetClip(rgn)
ClipRect(gBigRect)
SetControlValue(cH , value)
SetClip(rgn)
end if
end fn = value